package com.brayan.melinxa.gui.dialogs;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;
import javax.swing.JSeparator;

public class AboutDialog extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final JPanel contentPanel = new JPanel();

	public AboutDialog() {
		setResizable(false);
		setTitle("Melinxa Mirror - About");
		getContentPane().setBackground(Color.WHITE);
		setBounds(100, 100, 450, 360);
		getContentPane().setLayout(new BorderLayout());
		{
			JPanel panel = new JPanel();
			getContentPane().add(panel, BorderLayout.CENTER);
			panel.setLayout(new GridLayout(0, 1, 0, 0));
			panel.add(contentPanel);
			contentPanel.setBackground(Color.DARK_GRAY);
			contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
			contentPanel.setLayout(null);
			JLabel lblImage = new JLabel("(c)");
			lblImage.setBounds(10, 0, 248, 100);
			contentPanel.add(lblImage);
			lblImage.setBackground(Color.DARK_GRAY);
			lblImage.setIcon(new ImageIcon(AboutDialog.class.getResource("/media/Suivant-Sky-256.png")));
			this.repaint();
			{
				JTextPane txtpnMelinxaMirror = new JTextPane();
				txtpnMelinxaMirror.setBounds(268, 51, 166, 38);
				contentPanel.add(txtpnMelinxaMirror);
				txtpnMelinxaMirror.setForeground(SystemColor.text);
				txtpnMelinxaMirror.setBackground(Color.DARK_GRAY);
				txtpnMelinxaMirror.setContentType("text/html");
				txtpnMelinxaMirror.setEditable(false);
				txtpnMelinxaMirror
						.setText("<font size=\"6\" color=\"white\">Melinxa Mirror</font>");
			}
			{
				JPanel panel_1 = new JPanel();
				panel_1.setBackground(Color.WHITE);
				panel.add(panel_1);
				panel_1.setLayout(new BorderLayout(0, 0));
				{
					JTextPane txtpnAboutText = new JTextPane();
					txtpnAboutText.setContentType("text/html");

					panel_1.add(txtpnAboutText);
					txtpnAboutText
							.setText("<strong>A simple unidirectional data mirroring</strong>\r\n\r\n<p/>\r\n\r\nMelinxa Mirror shades data in a lazy and resource-cautious approach. The source directory sends and deletes the data-delta with the destination - never the other way around. It is uni-directional.");
					txtpnAboutText.setEditable(false);
				}
				
				JSeparator separator = new JSeparator();
				panel_1.add(separator, BorderLayout.NORTH);
			}
			{
				JPanel panel_1 = new JPanel();
				panel_1.setBackground(Color.WHITE);
				panel.add(panel_1);
				panel_1.setLayout(new BorderLayout(0, 0));
				{
					JTextPane txtpnAuthor = new JTextPane();
					txtpnAuthor.setContentType("text/html");
					txtpnAuthor
							.setText("\r\n&copy; 2013, Brayan Zimmerli<br>\r\nwww.brayan.com, Switzerland<br>\r\nVersion 1.0.2\r\n");
					txtpnAuthor.setFont(getFont());
					txtpnAuthor.setEditable(false);
					panel_1.add(txtpnAuthor, BorderLayout.SOUTH);
				}
			}
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						closeDialog();
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
		}
	}

	private void closeDialog() {
		this.dispose();
	}
}
